<?php

class ComercialService extends Model {

    /**
     * @var ComercialDao
     */
    private $comercialDao;

    public function injectDependencies() {
        $this->comercialDao = ComercialDao::getInstance();
    }

    public function generateSubscriptionReport(){
        $Report = array(
            'PERIOD' => $this->generatePeriodReport(),
            'MONTH' => $this->generateMonthlyReport(),
            'YEAR' => $this->generateYearlyReport()
        );
        return $Report;
    }

    public function generateCancelledReport(){
        $Report = array(
            'PERIOD' => $this->generateCancelledPeriodReport(),
            'MONTH' => $this->generateMonthlyCancelledReport(),
            'YEAR' => $this->generateYearlyCancelledReport()
        );
        return $Report;
    }

    private function generatePeriodReport() {
        $Report = array(
            '1-10' => $this->comercialDao->countNumberOfSubscriptionsByPeriod(1, 10),
            '11-20' => $this->comercialDao->countNumberOfSubscriptionsByPeriod(11, 20),
            '21-31' => $this->comercialDao->countNumberOfSubscriptionsByPeriod(21, 31),
        );
        return $Report;
    }

    private function generateCancelledPeriodReport() {
        $Report = array(
            '1-10' => $this->comercialDao->countNumberOfCancelledCustomersByPeriod(1, 10),
            '11-20' => $this->comercialDao->countNumberOfCancelledCustomersByPeriod(11, 20),
            '21-31' => $this->comercialDao->countNumberOfCancelledCustomersByPeriod(21, 31),
        );
        return $Report;
    }

     private function generateMonthlyReport() {
        $Report = array(
            'Janeiro' => $this->comercialDao->countNumberOfSubscriptionsByMonth(1),
            'Fevereiro' => $this->comercialDao->countNumberOfSubscriptionsByMonth(2),
            'Mar&ccedil;o' => $this->comercialDao->countNumberOfSubscriptionsByMonth(3),
            'Abril' => $this->comercialDao->countNumberOfSubscriptionsByMonth(4),
            'Maio' => $this->comercialDao->countNumberOfSubscriptionsByMonth(5),
            'Junho' => $this->comercialDao->countNumberOfSubscriptionsByMonth(6),
            'Julho' => $this->comercialDao->countNumberOfSubscriptionsByMonth(7),
            'Agosto' => $this->comercialDao->countNumberOfSubscriptionsByMonth(8),
            'Setembro' => $this->comercialDao->countNumberOfSubscriptionsByMonth(9),
            'Outubro' => $this->comercialDao->countNumberOfSubscriptionsByMonth(10),
            'Novembro' => $this->comercialDao->countNumberOfSubscriptionsByMonth(11),
            'Dezembro' => $this->comercialDao->countNumberOfSubscriptionsByMonth(12)
        );
        return $Report;
    }

     private function generateMonthlyCancelledReport() {
        $Report = array(
            'Janeiro' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(1),
            'Fevereiro' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(2),
            'Ma&ccedil;o' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(3),
            'Abril' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(4),
            'Maio' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(5),
            'Junho' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(6),
            'Julho' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(7),
            'Agosto' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(8),
            'Setembro' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(9),
            'Outubro' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(10),
            'Novembro' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(11),
            'Dezembro' => $this->comercialDao->countNumberOfCancelledCustomersByMonth(12)
        );
        return $Report;
    }

     private function generateYearlyReport() {
        return $this->comercialDao->countNumberOfSubscriptionsByYear();
    }

     private function generateYearlyCancelledReport() {
        return $this->comercialDao->countNumberOfCancelledCustomersByYear();
    }

}

?>
